package com.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created with IntelliJ IDEA.
 * User: xf
 * Date: 2016/4/12
 * Time: 22:07
 * To change this template use Editor | File and Code Templates.
 */
@Aspect
public class TestLearnAop {

    @Pointcut("execution(* com.service.impl.XfServiceImpl.aopLearn(..)) && args(response,request)")
    public void pointCut(HttpServletResponse response, HttpServletRequest request) {
    }

    @Around("pointCut(response,request)")
    public void doingMain(ProceedingJoinPoint joinPoint, HttpServletResponse response, HttpServletRequest request) {
        try {
            System.out.println("-----status-----" + response.getStatus());
            System.out.println("-----request url-----" + request.getRequestURI());
            System.out.println("我是参数，我进来了，");
            System.out.println("之前先嗨一下");
            joinPoint.proceed();
            System.out.println("结束了，还想来");
        } catch (Throwable throwable) {
            System.out.println("出错了");
            throwable.printStackTrace();
        }
    }

}
